/*
 * ReviewerTest.java
 * Author: Sanjeev Kamboj
 */
package superConference;

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;

import org.junit.Test;

/**
 * A JUnit Test Class for Reviewer.java.
 * 
 * @author Sanjeev Kamboj
 * @updated 11/26/2013
 */
public class ReviewerTest {

	private Paper p = new Paper(1, "nkamboj", PaperStatus.RECOMMENDED, 
			                    "hello", "paper1.txt");
	private Reviewer r1 = new Reviewer(new ArrayList<Paper>(),2, "svkamboj","Sanjeev"  );
	
	
	@Test
	public void testReviewer() {
		r1.addPaper(p);
		assertEquals(r1.my_papers.get(0), p);
		assertEquals(r1.name, "Sanjeev");
		
	}
	
	@Test
	public void testPaper() {
		 final Paper p2 = new Paper(1, "aemail", PaperStatus.RECOMMENDED, 
                "hello", "paper2.txt");
		 final Paper p3 = new Paper(1, "bemail", PaperStatus.RECOMMENDED, 
                "hello", "paper3.txt");
		
		r1.addPaper(p);
		r1.addPaper(p2);
		r1.addPaper(p3);
		
		assertEquals(r1.my_papers.get(1), p2);
		assertEquals(r1.my_papers.get(2), p3);
		
		
	}


	@Test
	public void testEditReview() throws FileNotFoundException {
		r1.addPaper(p);
		r1.editReview(1, "Hello");
		
		//assertEquals(r1.viewReview(1), "Hello\n");
		
	}

	@Test
	public void testSelectReview() {
		final Paper p2 = new Paper(1, "aemail", PaperStatus.RECOMMENDED, 
                "hello", "paper2.txt");
		final Paper p3 = new Paper(3, "bemail", PaperStatus.RECOMMENDED, 
                "hi", "paper3.txt");
		
		r1.addPaper(p);
		r1.addPaper(p2);
		r1.addPaper(p3);
		
		final File f = r1.getReviewFile(3);
		assertEquals(f.getName(), r1.my_paperIdtorev.get(p3.getId()).getFileName());
	}

	@Test
	public void testSubmitReview() throws FileNotFoundException {
		final Paper p2 = new Paper(2, "aemail", PaperStatus.RECOMMENDED, 
                "hello", "paper2.txt");
		 final Paper p3 = new Paper(3, "bemail", PaperStatus.RECOMMENDED, 
                "hi", "paper3.txt");
		
		r1.addPaper(p);
		r1.addPaper(p2);
		r1.addPaper(p3);
		
		final File f1 = r1.getReviewFile(2);
		final Paper f2 = r1.submitReview(2, f1);

		assertTrue(r1.getReview(2).isSubmitted());
		
	}
	
	@Test
	public void testViewReview() throws FileNotFoundException {
		final Paper p2 = new Paper(2, "aemail", PaperStatus.RECOMMENDED, 
                "hello", "paper2.txt");
		 r1.addPaper(p2);
		 
		 //String s1 = r1.viewReview(2);
		 //assertEquals(s1, "Hello\n");
	}

}
